﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChronoScript_Compiler.Language.Parser
{
    public partial class Parser
    {
        public List<Token> tokens;
        public List<LanguageDefinition.SyntaxNode> AST = new List<LanguageDefinition.SyntaxNode>();
        int index = 0;

        public Parser(List<Token> tokens)
        {
            this.tokens = tokens;
        }

        public Token PeekToken(int depth = 0)
        {
            return tokens[index + depth];
        }
        public Token ReadToken(int depth = 0)
        {
            index = index + depth + 1;
            return tokens[index-1];
        }

        public void Parse()
        {
            while (index < tokens.Count)
            {
                if (PeekToken() is Tokens.SemiColon)
                {
                   ReadToken();
                    continue;
                }
                if (PeekToken() is Tokens.Statement && PeekToken(1) is Tokens.Statement && PeekToken(2) is Tokens.openParenthesis)
                    AST.Add(ParseMethod());
            }
        }
    }
}
